<?php
/**
* @package readerTemplate
* @author Jan Papousek
* @copyright Jan Papousek 2007
* @link http://ctenar.cz
*/
/**
* Literární soutěž	
* @package readerTemplate
*/
class CompetitionInfo extends Div {
	
	public function __construct($comp) {
		parent::__construct();
		$this->setClass("competition");
		
		// Nadpis souteze (titulek diskusniho prispevku
		$this->addValue(new H(2,new a(
			$comp->title,
			"competition.php?action=readOne&amp;topic=".$comp->topicID."&amp;follow=$comp->id"
		)));
		$info = new Div();
		
		// Datum
		$date = new Span(new String(String::dateFormat($comp->date)));
		$date->setClass("date");
		$info->addValue($date);
		unset($date);
		
		// Pokud je prihlaseny uzivatel moderator nebo vlastnik prispevku, ma moznost jej smazat
		$owner = Page::session("login");
		if (($owner->level > User::LEVEL_COMMON) || ($owner->id == $comp->userID)) {
			$admin = new A(
				Lng::DELETE,
				"competition.php?action=competitionDestroy&amp;discussion=".$comp->id."&amp;topic=".Page::get("topic")."&amp;follow=".Page::get("follow")
			);
			$admin->setClass("admin");
			$admin->addEvent("onclick","return confirm('".Lng::ASSURANCE_COMPETITION." ".$comp->title."');");
			$info->addValue($admin);
			unset($admin);
		}
		
		// Autor prispevku
		$author = new A(
			$comp->userName,
			"user.php?user=".$comp->userID
		);
		$author->setClass("author");
		$info->addValue($author);
		unset($author);
		
		
		$this->addValue($info);
		unset($info);
		
		// Obsah prispevku
		$content = new Div(new String($comp->text,TRUE));
		$content->setClass("content");
		$this->addValue($content);
		unset($content);
	}
}
?>